import 'element-plus/dist/index.css';
import { ElMessage } from 'element-plus';
import { h, reactive, withDirectives } from 'vue';
import JiessMidder from '@jiess/utils/midder';
import {
	$Area,
	$SuperTable,
	$tanInstance,
	$ActionButton,
	$ActionButtons,
	$dialogInstance,
	$TableTools,
	$TableFilter,
	$ExpandFilter,
	// --------------
	$modules
} from '@/.jiess';
import '@/.jiess/vue3element/css/base.css';
// ===============================================================
export const tools = $modules;
export default {
	install: (app) => {
		const { JiessEnv, $entry, $component } = $modules;
		const jiess = $entry(JiessEnv,
			// 静态注入到jiess实例中
			{
				h,
				reactive,
				withDirectives,
			},
			// 动态注入到组件上下文中
			{
				area: $Area,
				$tan: $tanInstance,
				dialog: $dialogInstance,
				// 定义项目共享中介者
				$midder: new JiessMidder('GlobalMidder', 'no-store'),
				// 注入全局的消息提示
				$msg: (message, type = 'success') => ElMessage({ message, type }),
			});
		app.config.globalProperties.$jiess = jiess;
		app.component('jiess', jiess.JiessComponent);
		$component('jiess', jiess.JiessComponent);
		$component($SuperTable.name, $SuperTable);
		$component($ActionButton.name, $ActionButton);
		$component($ActionButtons.name, $ActionButtons);
		$component($TableTools.name, $TableTools);
		$component($TableFilter.name, $TableFilter);
		$component($ExpandFilter.name, $ExpandFilter);
	}
}